import { BasicColumn, FormSchema } from "/@/components/Table";
import { render } from "/@/utils/common/renderUtils";

//列表数据
export const columns: BasicColumn[] = [
  {
    title: '申请时间',
    align: "center",
    sorter: true,
    dataIndex: 'createTime'
  },
  {
    title: '开票类目',
    align: "center",
    dataIndex: 'categoryText'
  },
  {
    title: '开票金额',
    align: "center",
    dataIndex: 'amount',
    customRender:({text}) =>{
      return !text ? "0.00" : text.toFixed(2);
    },
  },
  {
    title: '开票类型',
    align: "center",
    dataIndex: 'type',
    slots: { customRender: 'typeSlot' },
  },
  {
    title: '收件类型',
    align: "center",
    dataIndex: 'receivedType',
    slots: { customRender: 'receivedTypeSlot' },
  },
];
export const columns1: BasicColumn[] = [
  {
    title: '提交时间',
    align: "center",
    sorter: true,
    dataIndex: 'submitTime'
  },
]
export const columns2: BasicColumn[] = [
  {
    title: '审核时间',
    align: "center",
    sorter: true,
    dataIndex: 'checkTime'
  },
]
export const columns3: BasicColumn[] = [
  {
    title: '驳回理由',
    align: "center",
    dataIndex: 'rejectReason'
  },
]
export const columns4: BasicColumn[] = [
  {
    title: '完成时间',
    align: "center",
    sorter: true,
    dataIndex: 'finishTime'
  },
]

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "创建日期",
    field: "createTime",
    component: 'RangePicker',
    componentProps: {
      showTime: true,
    },
    colProps: {span: 6},
  },
  {
    label: "开票类目",
    field: 'categoryId',
    component: 'JCategorySelect',
    componentProps:{
      pcode: "",//back和事件未添加，暂时有问题
    },
    colProps: {span: 6},
  },
  {
    label: "开票类型：1-普通发票，2-增值税专用发票",
    field: 'type',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "caishui_bill_type"
    },
    colProps: {span: 6},
  },
  {
    label: "收件类型：1-电子发票，2-纸质发票",
    field: 'receivedType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "caishui_bill_received_type"
    },
    colProps: {span: 6},
  },
  {
    label: "审核时间",
    field: "checkTime",
    component: 'RangePicker',
    componentProps: {
      showTime: true,
    },
    colProps: {span: 6},
  },
  {
    label: "开票完成时间",
    field: "finishTime",
    component: 'RangePicker',
    componentProps: {
      showTime: true,
    },
    colProps: {span: 6},
  },
  {
    label: "状态：0-审核中，1-开票中，2-审核驳回，3-开票完成",
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "caishui_bill_status"
    },
    colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '税源地ID',
    field: 'companyId',
    component: 'Input',
  },
  {
    label: '商户ID',
    field: 'businessId',
    component: 'Input',
  },
  {
    label: '订单编号',
    field: 'orderNo',
    component: 'Input',
  },
  {
    label: '企业名称',
    field: 'businessName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入企业名称!'},
             ];
    },
  },
  {
    label: '企业电话',
    field: 'businessPhone',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入企业电话!'},
             ];
    },
  },
  {
    label: '企业税号',
    field: 'businessTax',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入企业税号!'},
             ];
    },
  },
  {
    label: '企业地址',
    field: 'businessAddress',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入企业地址!'},
             ];
    },
  },
  {
    label: '开户行',
    field: 'businessBankName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入开户行!'},
             ];
    },
  },
  {
    label: '银行账号',
    field: 'businessBankAccount',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入银行账号!'},
             ];
    },
  },
  {
    label: '开票类目',
    field: 'categoryId',
    component: 'JCategorySelect',
    componentProps:{
      pcode: "", //TODO back和事件未添加，暂时有问题
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入开票类目!'},
             ];
    },
  },
  {
    label: '开票金额',
    field: 'amount',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入开票金额!'},
              { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
             ];
    },
  },
  {
    label: '开票类型：1-普通发票，2-增值税专用发票',
    field: 'type',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "caishui_bill_type"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入开票类型：1-普通发票，2-增值税专用发票!'},
             ];
    },
  },
  {
    label: '右下角备注信息',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '收件类型：1-电子发票，2-纸质发票',
    field: 'receivedType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "caishui_bill_received_type"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入收件类型：1-电子发票，2-纸质发票!'},
             ];
    },
  },
  {
    label: '收件人',
    field: 'receivedName',
    component: 'Input',
  },
  {
    label: '收件电话',
    field: 'receivedPhone',
    component: 'Input',
  },
  {
    label: '收件地址',
    field: 'receivedAddress',
    component: 'Input',
  },
  {
    label: '审核时间',
    field: 'checkTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
  {
    label: '驳回理由',
    field: 'rejectReason',
    component: 'Input',
  },
  {
    label: '电子发票',
    field: 'electronicInvoice',
    component: 'JUpload',
    componentProps:{
     },
  },
  {
    label: '发票寄出相关照片',
    field: 'billImg',
    component: 'JImageUpload',
    componentProps:{
    },
  },
  {
    label: '开票完成时间',
    field: 'finishTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
  {
    label: '状态：0-审核中，1-开票中，2-审核驳回，3-开票完成',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "caishui_bill_status"
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
